{
    // 数组对象去重
    let arr = [
        {
            key:'01',
            value:'乐乐'
        },
        {
            key:'02',
            value:'哈哈'
        },
        {
            key:'01',
            value:'乐乐'
        }
    ];
    let obj = {};
    arr = arr.reduce(function (item, value) {
        obj[value.key] ? '' : obj[value.key] = true && item.push(value)
        return item
    }, []);
}

{
    // js数组对象, 取对象键名和键值为新数组
    /*
    数组格式： 	[{ "app1": 1, "app2": 2 }, { "app1": 8, "app2": 10 }]
    期望结果：
    app1: [1,8]
    app2:[2,10]

     */
    let arr = [{ "app1": 1, "app2": 2 }, { "app1": 8, "app2": 10 }];
    let obj = {};
    arr.forEach(item => {
        Object.keys(item).forEach(subItem => {
            obj.hasOwnProperty(subItem) ? obj[subItem].push(item[subItem]) : obj[subItem] = [item[subItem]]
        })
    })
    console.log(obj)
}
{
    // 将两个数组对象合并成一个数组
    // es6扩展运算符的作用
    // ...arr返回的并不是一个数组，而是各个数组的值
    let obj1 = [{
        "id": 980550455852,
        "model": "XQG70-S1208FW",
        "color": "白",
        "invStatusName": "正品",
        "bactualQty": 10947,
        "brealyQty": 11000,
        "bavailQty": 53
    }, {
        "id": 980550566221,
        "model": "XQB70-C3006",
        "color": "灰",
        "invStatusName": "正品",
        "bactualQty": 11,
        "brealyQty": 6,
        "bavailQty": -5
    }];
    let obj2 = [{
        "price": "6666"
    }, {
        "price": "8888"
    }];
    let obj = obj1.map((item, index) => {
        return {
            ...item,
            ...obj2[index]
        }
    })
    console.log(obj)
}
{
    // es6扩展运算符的作用
    let [a,...rest] = [1,2,3,4];
    console.log(a);
    console.log(rest);

    let demo = function (a,...arg){
        console.log(a);
        console.log(arg);
    }
    demo(1,2,3,4);
    // 1
    // [2, 3, 4]

    let demo2 = "hello"
    let str2 = [...demo2];
    console.log(str2);
    // ["h", "e", "l", "l", "o"]

    let arr1 = [1,2,3];
    let arr2 = [4,5,6];
    let demo3 = [...arr1,...arr2];
    console.log(demo3);

    Array.prototype.push.apply(arr1, arr2);  // 方法2合并数组
    arr1.push.apply(arr1, arr2);   // 方法3合并数组
    [].push.apply(arr1, arr2);     // 方法3合并数组
//  [1, 2, 3, 4, 5, 6]
}
{
    function foo() {
        let a = b = 0;
        a++;
        return a;
    }

    foo();
    typeof a; // => ???
    typeof b; // => ???
    console.log(typeof a);
    console.log(typeof b)
}